﻿#region zh-CHS 2010 - 2010 DemoSoft 团队 | en 2010-2010 DemoSoft Team

//     NOTES
// ---------------
//
// This file is a part of the MMOCE(Massively Multiplayer Online Client Engine) for .NET.
//
//                              2010-2010 DemoSoft Team
//
//
// First Version : by H.Q.Cai - mailto:caihuanqing@hotmail.com

/***************************************************************************
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU Lesser General Public License as published
 *   by the Free Software Foundation; either version 2.1 of the License, or
 *   (at your option) any later version.
 *
 ***************************************************************************/

#region zh-CHS 包含名字空间 | en Include namespace
using System.Collections.Generic;
using Demo.Silverlight.Core.Common.SafeCollections;
#endregion

namespace Demo.Silverlight.Core.Common.Template
{
    /// <summary>
    /// 
    /// </summary>
    public class SupportTemplate<TemplateT> : ISupportTemplate<TemplateT>
        where TemplateT : ITemplateSerial
    {

        #region zh-CHS 私有成员变量 | en Private Member Variables
        /// <summary>
        /// 
        /// </summary>
        private SafeMultiDictionary<long, TemplateT> m_TemplateDictionary = new SafeMultiDictionary<long, TemplateT>( false );
        #endregion
        /// <summary>
        /// 
        /// </summary>
        /// <param name="templateId"></param>
        /// <returns></returns>
        public void AddTemplate( TemplateT templateT )
        {
            m_TemplateDictionary.Add( templateT.TemplateSerial, templateT );
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public void RemoveTemplate( TemplateT templateT )
        {
            m_TemplateDictionary.Remove( templateT.TemplateSerial, templateT );
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="templateId"></param>
        /// <returns></returns>
        public IEnumerable<TemplateT> FindTemplateOnId( long templateId )
        {
            IEnumerable<TemplateT> outTemplate = null;
            m_TemplateDictionary.TryGetValues( templateId, out outTemplate );

            return outTemplate;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="iQuestId"></param>
        public void Clear()
        {
            m_TemplateDictionary.Clear();
        }

    }
}
#endregion